package inactivescenery;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

public class QuestionScenery {
	private String question;
	private int count;
	private final int MAXCOUNT= 3;
	private boolean isFinished;
	private int stringLength;
	private int drewIndex;
	private int x;
	private int y;
	private Color questionColor;
	private String drewString;
	
	public QuestionScenery(String question, int x, int y){
		this.question = question;
		this.x = x;
		this.y = y;
		stringLength = question.length();
		drewIndex = 0;
		drewString = "";
		isFinished = false;
		count = 0;
		questionColor = new Color(0, 0, 0);
	}
	public void draw(Graphics2D g){
		Color c = g.getColor();
		Font f = g.getFont();
		g.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
		g.setColor(questionColor);
		if(!isFinished){
			if(count == 0){
				drewString = "";
				drewString = question.substring(0, drewIndex);
				drewIndex++;
				drewString += "_";
			}else if(count == 1){
				drewString = question.substring(0, drewString.length() - 1);
			}else{
				drewString += "_";
				count = 0;
			}
			int w = g.getFontMetrics().stringWidth(drewString);
			////
			if(w > x -5){
				drewString = "";
			}
			/////
			g.drawString(drewString, x + 5, y + f.getSize());
		}else{
			g.drawString(question, x + 5, y + f.getSize());
		}
		g.setFont(f);
		g.setColor(c);
	}
}
